Skip to content

Feat(formal-verification): port statechart compiler and formal verification skills - #24

Merged
jtaroreh merged 1 commit into
mainfrom
feat/agystack-pr2-formal-verification
Nov 23, 2026
Merged

jtaroreh merged 1 commit into
mainfrom
feat/agystack-pr2-formal-verification

Conversation

@jtaroreh

Copy link
Copy Markdown
Owner

Why

agystack stripped formal verification upkeep and replaced statechart with hand-written diagrams. That dropped code-to-model traceability, scratch-break mutation proofs, and TLC model checking. Porting the upstream formal verification skills and TLA+ statechart compiler restores those checks while rendering results natively in Antigravity Brain Artifacts.

Scope

  • Created skills/maintain-formal-verification-skill/SKILL.md with four outcomes (in sync, updated, bug, blocked), verification-only edit scope, six-step sync-commit diff pass, mandatory scratch-break mutation proof, and output to formal_verification_report.md.
  • Upgraded skills/create-formal-verification-skill/SKILL.md to keep agystack's four-domain applicability quick selector and formal_verification_report.md artifact output while restoring code-to-model traceability, indivisible-step fidelity, scratch-break proof, anti-weakening guard (findings stay findings), coverage map plus sync-commit SHA, and links to /statechart and /maintain-formal-verification-skill.
  • Updated skills/statechart/SKILL.md for Mode 1 (verified TLC model via scripts/statechart, embedding chart.mmd and report.md into statechart_<slug>.md) and Mode 2 (explicitly labeled unverified design sketches), and created skills/statechart/references/render.md for optional Pele SVG export.
  • Ported the upstream TypeScript compiler, POSIX statechart launcher, and offline test/ corpus into skills/statechart/scripts/, renamed @cursor-skill/statechart to @agystack/statechart in skills/statechart/scripts/package.json, and updated linkedLauncher in skills/statechart/scripts/test/cli.test.ts to resolve fs.realpathSync(os.tmpdir()) so relative symlink tests pass on macOS /var symlinks.
  • Added */scripts/test/* exclusions and required statechart / statechart.ts / pipeline.ts archive assertions in scripts/package-plugin.sh, added test-statechart to Makefile, and indexed /maintain-formal-verification-skill in README.md.

Tradeoffs

  • scripts/package-plugin.sh ships the ~200 KB compiler and strips the 3.6 MB skills/statechart/scripts/test/ tree from release zips instead of shipping fixtures, keeping agystack-0.17.0.zip at 478,633 bytes (+64,485 bytes vs trunk 414,148 bytes).
  • skills/statechart/scripts/test/cli.test.ts resolves os.tmpdir() via fs.realpathSync so linkedLauncher computes the true relative depth on macOS /private/var, leaving compiler TypeScript and corpus fixtures unchanged.

Blast Radius

This PR touches only the formal-verification skills, skills/statechart/scripts/, packaging exclusions in scripts/package-plugin.sh, Makefile, and one README.md catalog row. tests/test_antigravity_invariants.py and tests/test_skill_catalog.py pass with zero .cursor leakage across skills.

Verification

  • uv run ruff check . and make lint passed with zero errors (shellcheck skipped locally because it is not installed on PATH).
  • uv run pytest -v tests/ passed (412 passed, 3 skipped, 153 subtests passed in 24.17s; the 3 skips are live GCS tests gated on AGYSTACK_LIVE_BUCKET).
  • bun run typecheck and bun test in skills/poteto-mode/scripts passed (47 pass, 0 fail).
  • make test-statechart passed (229 pass, 0 fail across pipeline.test.ts, messages.test.ts, chart.test.ts, and cli.test.ts in 60.33s; cli.test.ts runs 159 sequential child-process tests).
  • skills/statechart/scripts/statechart --help printed usage and exited 2 under both Node v24.9.0 and Bun 1.3.14.
  • uv run python skills/setup-agystack/scripts/setup_runtime.py --doctor returned OK.
  • bash scripts/package-plugin.sh --test passed, and bash scripts/package-plugin.sh produced a 478,633-byte archive containing skills/statechart/scripts/pipeline.ts and statechart.ts with zero scripts/test entries.

@jtaroreh

Copy link
Copy Markdown
Owner Author

Verification Verdict: CLEAN at bc5e91a5066d7cb864c54136e61875e6222610ba

  • Unit & Gates: ruff check ., pytest -v tests/ (412 passed, 3 skipped, 153 subtests), bun test (47 passed), make test-statechart (229 passed), setup_runtime.py --doctor (OK), and scripts/package-plugin.sh --test all exited 0.
  • Live (10/10 PASS): pipeline.test.ts + messages.test.ts (18 passed), chart.test.ts (52 passed), cli.test.ts (159 passed), regionsLie mutation proof (mutant exit 1 / 7 failed, reverted exit 0 / 52 passed), Node and Bun statechart --help parity, zip audit (pipeline.ts present, zero scripts/test/ entries), package-plugin.sh --test, test_antigravity_invariants.py + test_skill_catalog.py (19 passed), statechart/SKILL.md Brain Artifact separation, and formal verification skill checks. Receipts in /tmp/swarm-pr2/.
  • Perf: Release zip size 478,633 bytes (+64,485 bytes vs trunk 414,148 bytes, well under 100 KB limit). make test-statechart offline non-CLI tests run in 1.18 s median (1.90%), while upstream cli.test.ts spawns 159 child processes taking 61.13 s median on macOS (accepted by operator; documented in decisions.tsv).
  • Independent Audit & Interrogate (PASS): Strict 8-area scope verified; PR chore(ci): harden CI, release, Ruff, packaging, and test isolation #22 packaging flags and Makefile targets preserved; zero Cursor leaks; zero Bugbot/review threads.
  • Stack position: Appended as PR Feat(formal-verification): port statechart compiler and formal verification skills #24 above PR feat(agystack): encode Antigravity invariants and align skill catalog #23 (feat/agystack-pr1-invariants).

@jtaroreh

Copy link
Copy Markdown
Owner Author

Independent PR Verification Verdict: PASS+NOTES

  • Head SHA: bc5e91a5066d7cb864c54136e61875e6222610ba
  • Patch ID (git patch-id --stable vs origin/feat/agystack-pr1-invariants): c299c6886be0465feaa088147fb871857948dfde
  • PR State: mergeable: MERGEABLE, mergeStateStatus: CLEAN, reviewDecision: (none), statusCheckRollup: []

Diff & Invariant Review

  • Scope (415 files changed, 20462 insertions(+), 63 deletions(-)): Adds the TypeScript statechart compiler (skills/statechart/scripts/), skills/statechart/SKILL.md (Mode 1 TLC model + Mode 2 design sketch), skills/statechart/references/render.md, skills/maintain-formal-verification-skill/SKILL.md, updates skills/create-formal-verification-skill/SKILL.md, Makefile (test-statechart), README.md, and scripts/package-plugin.sh.
  • Antigravity Invariants & Cursor Leakage: Zero Cursor or pstack leakage in all non-test files. Artifacts route to <appDataDir>/brain/<conversation-id>/ with ArtifactMetadata, and test_zero_cursor_leakage_across_skills passed.
  • Packaging Exclusions: scripts/package-plugin.sh excludes */scripts/test/*, */scripts/test/, *.test.ts, and *.test-helper.ts, and explicitly asserts skills/statechart/scripts/{statechart,statechart.ts,pipeline.ts} are present in the zip.

Verification Commands & Results

  1. ruff check . passed (All checks passed!, exit 0).
  2. pytest -v tests/ passed (412 passed, 3 skipped, 153 subtests passed in 53.14s, exit 0; the 3 skipped tests are live GCS tests in tests/test_live_cloud_bidirectional.py).
  3. (cd skills/poteto-mode/scripts && bun run typecheck && bun test) passed after bun install --frozen-lockfile (tsc --noEmit --strict exit 0; 47 pass, 0 fail, 159 expect() calls across 4 files).
  4. make test-statechart passed (229 pass, 0 fail, 0 skipped across pipeline.test.ts, messages.test.ts, chart.test.ts, and cli.test.ts).
  5. python3 skills/setup-agystack/scripts/setup_runtime.py --doctor returned "status": "OK" (exit 0; optional gt and cloud Python packages absent).
  6. bash scripts/package-plugin.sh --test passed archive verification for agystack v0.17.0 (agy CLI not on PATH, so strict CLI validation skipped).
  7. Zip archive inspection (package-plugin.sh --output-dir <tmp>) confirmed 281 entries, skills/statechart/scripts/pipeline.ts present (True), and 0 test entries (*/scripts/test/* and *.test.ts excluded).

Notes

  • agy CLI was absent from PATH, so agy plugin validate --strict was skipped during package-plugin.sh --test.
  • make test-statechart exercises the TypeScript compiler and CLI against recorded TLC fixtures (java.ts replay); live corpus.test.ts execution requires TLA2TOOLS / mise TLC installation.
  • Recorded upstream TLC output files under skills/statechart/scripts/test/corpus/ retain historical /agent/repos/plugins/pstack/... paths from when fixtures were recorded; these test directories are excluded from the distributed zip.
  • In a fresh worktree, skills/poteto-mode/scripts required bun install --frozen-lockfile before bun run typecheck and cli.test.ts could resolve bun-types and commander.
  • On an initial pytest -v tests/ run under heavy concurrent host load, tests/test_simulation_scenario.py::TestSimulationScenarioWorkflow::test_end_to_end_simulation_run hit a pre-existing STEER_RECEIVED mailbox timing race; both an isolated re-run (8 passed) and a subsequent full pytest -v tests/ run (412 passed, 3 skipped) passed cleanly.

@jtaroreh
jtaroreh changed the base branch from feat/agystack-pr1-invariants to main November 23, 2026 00:48
…cation skills

Restore upstream create-formal-verification-skill rigor and add maintain-formal-verification-skill targeting Antigravity Brain Artifact formal_verification_report.md. Port the upstream TLA+ statechart compiler and offline test suite into skills/statechart/scripts, integrate dual-mode Brain Artifact rendering and Pele SVG export, exclude test fixtures from release zips in scripts/package-plugin.sh, add make test-statechart, and index the new skill in README.md.
@jtaroreh
jtaroreh force-pushed the feat/agystack-pr2-formal-verification branch from bc5e91a to 73428c5 Compare November 23, 2026 00:48
@jtaroreh
jtaroreh merged commit 08474f9 into main Nov 23, 2026
2 of 4 checks passed
@jtaroreh
jtaroreh deleted the feat/agystack-pr2-formal-verification branch November 23, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant